﻿namespace AC.ExtendedRenderer.Toolkit.Drawing
{
    using System;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Windows.Forms;

    public static class DrawingMethods
    {
        public static void ClearTabSelectedBottomLine(Graphics g, Rectangle recBounds, Pen pen, TabAlignment Alignment)
        {
            switch (Alignment)
            {
                case TabAlignment.Top:
                    g.DrawLine(pen, recBounds.Left + 1, recBounds.Bottom, recBounds.Right - 1, recBounds.Bottom);
                    g.DrawLine(pen, (int) (recBounds.Left + 1), (int) (recBounds.Bottom + 1), (int) (recBounds.Right - 1), (int) (recBounds.Bottom + 1));
                    return;

                case TabAlignment.Bottom:
                    g.DrawLine(pen, recBounds.Left + 1, recBounds.Top, recBounds.Right - 1, recBounds.Top);
                    g.DrawLine(pen, (int) (recBounds.Left + 1), (int) (recBounds.Top - 1), (int) (recBounds.Right - 1), (int) (recBounds.Top - 1));
                    g.DrawLine(pen, (int) (recBounds.Left + 1), (int) (recBounds.Top - 2), (int) (recBounds.Right - 1), (int) (recBounds.Top - 2));
                    return;

                case TabAlignment.Left:
                    g.DrawLine(pen, recBounds.Right, recBounds.Top + 1, recBounds.Right, recBounds.Bottom - 1);
                    g.DrawLine(pen, (int) (recBounds.Right + 1), (int) (recBounds.Top + 1), (int) (recBounds.Right + 1), (int) (recBounds.Bottom - 1));
                    g.DrawLine(pen, (int) (recBounds.Right + 2), (int) (recBounds.Top + 1), (int) (recBounds.Right + 2), (int) (recBounds.Bottom - 1));
                    g.DrawLine(pen, (int) (recBounds.Right + 3), (int) (recBounds.Top + 1), (int) (recBounds.Right + 3), (int) (recBounds.Bottom - 1));
                    return;

                case TabAlignment.Right:
                    g.DrawLine(pen, recBounds.Left, recBounds.Top + 1, recBounds.Left, recBounds.Bottom - 1);
                    g.DrawLine(pen, (int) (recBounds.Left - 1), (int) (recBounds.Top + 1), (int) (recBounds.Left - 1), (int) (recBounds.Bottom - 1));
                    g.DrawLine(pen, (int) (recBounds.Left - 2), (int) (recBounds.Top + 1), (int) (recBounds.Left - 2), (int) (recBounds.Bottom - 1));
                    g.DrawLine(pen, (int) (recBounds.Left - 3), (int) (recBounds.Top + 1), (int) (recBounds.Left - 3), (int) (recBounds.Bottom - 1));
                    return;
            }
        }

        public static Color ColorFromAhsb(int Alpha, float Hue, float Saturation, float Brightness)
        {
            float num;
            float num2;
            float num3;
            if ((0 > Alpha) || (0xff < Alpha))
            {
                throw new ArgumentOutOfRangeException("a", Alpha, "InvalidAlpha");
            }
            if ((0f > Hue) || (360f < Hue))
            {
                throw new ArgumentOutOfRangeException("h", Hue, "InvalidHue");
            }
            if ((0f > Saturation) || (1f < Saturation))
            {
                throw new ArgumentOutOfRangeException("s", Saturation, "InvalidSaturation");
            }
            if ((0f > Brightness) || (1f < Brightness))
            {
                throw new ArgumentOutOfRangeException("b", Brightness, "InvalidBrightness");
            }
            if (0f == Saturation)
            {
                return Color.FromArgb(Alpha, Convert.ToInt32((float) (Brightness * 255f)), Convert.ToInt32((float) (Brightness * 255f)), Convert.ToInt32((float) (Brightness * 255f)));
            }
            if (0.5 < Brightness)
            {
                num = (Brightness - (Brightness * Saturation)) + Saturation;
                num3 = (Brightness + (Brightness * Saturation)) - Saturation;
            }
            else
            {
                num = Brightness + (Brightness * Saturation);
                num3 = Brightness - (Brightness * Saturation);
            }
            int num4 = (int) Math.Floor((double) (Hue / 60f));
            if (300f <= Hue)
            {
                Hue -= 360f;
            }
            Hue /= 60f;
            Hue -= 2f * ((float) Math.Floor((double) (((num4 + 1f) % 6f) / 2f)));
            if ((num4 % 2) == 0)
            {
                num2 = (Hue * (num - num3)) + num3;
            }
            else
            {
                num2 = num3 - (Hue * (num - num3));
            }
            int green = Convert.ToInt32((float) (num * 255f));
            int red = Convert.ToInt32((float) (num2 * 255f));
            int blue = Convert.ToInt32((float) (num3 * 255f));
            switch (num4)
            {
                case 1:
                    return Color.FromArgb(Alpha, red, green, blue);

                case 2:
                    return Color.FromArgb(Alpha, blue, green, red);

                case 3:
                    return Color.FromArgb(Alpha, blue, red, green);

                case 4:
                    return Color.FromArgb(Alpha, red, blue, green);

                case 5:
                    return Color.FromArgb(Alpha, green, blue, red);
            }
            return Color.FromArgb(Alpha, green, red, blue);
        }

        public static GraphicsPath CreateRectGraphicsPath(Rectangle rect)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(rect);
            return path;
        }

        public static void DrawContentFromOneColor(Graphics g, Rectangle rect, float baseHue, float Angle)
        {
            Color color = ColorFromAhsb(0xff, baseHue, 0.2958f, 0.7292f);
            Color color2 = ColorFromAhsb(0xff, baseHue, 0.5875f, 0.35f);
            Color color3 = ColorFromAhsb(0xff, baseHue, 0.7458f, 0.2f);
            Color color4 = ColorFromAhsb(0xff, baseHue, 0.6f, 0.4042f);
            Rectangle rectangle = new Rectangle(0, 0, rect.Width, rect.Height / 2);
            Rectangle rectangle2 = new Rectangle(0, rectangle.Height, rect.Width, (rect.Height - rectangle.Height) - 1);
            using (Brush brush = new LinearGradientBrush(rectangle, color, color2, Angle))
            {
                g.FillRectangle(brush, rectangle);
            }
            using (Brush brush2 = new LinearGradientBrush(rectangle2, color3, color4, Angle))
            {
                g.FillRectangle(brush2, rectangle2);
            }
        }

        public static void DrawGradient(Graphics g, Rectangle rect, Color DarkColor, Color LightColor, float Angle, bool EnableBorder, Color BorderColor, float BorderSize)
        {
            using (LinearGradientBrush brush = new LinearGradientBrush(rect, LightColor, DarkColor, Angle))
            {
                Blend blend = new Blend(4);
                blend.Positions[0] = 0f;
                blend.Factors[0] = 0.9f;
                blend.Positions[1] = 0.4f;
                blend.Factors[1] = 0.5f;
                blend.Positions[2] = 0.4f;
                blend.Factors[2] = 0.2f;
                blend.Positions[3] = 1f;
                blend.Factors[3] = 1f;
                brush.Blend = blend;
                g.FillRectangle(brush, rect);
            }
            if (EnableBorder)
            {
                g.DrawRectangle(new Pen(BorderColor, BorderSize), rect);
            }
        }

        public static void DrawLinearGradientTwoParts(Graphics g, Rectangle rect, Color LightColor, Color MiddleColor1, Color MiddleColor2, Color DarkColor, float Angle)
        {
            Rectangle rectangle = new Rectangle();
            Rectangle rectangle2 = new Rectangle();
            rectangle = rect;
            rectangle2 = rect;
            rectangle.Height = rect.Height / 2;
            rectangle.Width = rect.Width;
            rectangle.X = rect.X;
            rectangle.Y = rect.Y;
            rectangle2.Height = rect.Height - rectangle.Height;
            rectangle2.Width = rect.Width;
            rectangle2.X = rect.X;
            rectangle2.Y = rect.Y + rectangle.Height;
            LinearGradientBrush brush = new LinearGradientBrush(rectangle, LightColor, MiddleColor1, LinearGradientMode.Vertical);
            LinearGradientBrush brush2 = new LinearGradientBrush(rectangle2, MiddleColor2, DarkColor, LinearGradientMode.Vertical);
            g.FillRectangle(brush, rectangle);
            g.FillRectangle(brush2, rectangle2);
        }

        public static void DrawListViewHeader(Graphics g, Rectangle rect, Color LightColor, Color DarkColor, float Angle)
        {
            if (DarkColor == Color.White)
            {
                DarkColor = Color.Snow;
            }
            using (Brush brush = GetBrush(rect, LightColor, DarkColor, PaletteColorStyle.Default, Angle, VisualOrientation.Top, false))
            {
                g.FillRectangle(brush, rect);
            }
        }

        public static void DrawListViewHeader2(Graphics g, Rectangle rect, Color LightColor, Color MiddleColor, Color DarkColor, Color ExtraColor, float Angle)
        {
            int num = (rect.Height / 2) - 2;
            Rectangle rectangle = new Rectangle(rect.X, rect.Y + num, rect.Width, rect.Height - num);
            if ((MiddleColor == Color.White) && (DarkColor == Color.White))
            {
                MiddleColor = Color.WhiteSmoke;
                DarkColor = Color.Snow;
            }
            using (LinearGradientBrush brush = new LinearGradientBrush(rect, LightColor, MiddleColor, Angle))
            {
                g.FillRectangle(brush, rect);
            }
            using (LinearGradientBrush brush2 = new LinearGradientBrush(rectangle, MiddleColor, DarkColor, Angle))
            {
                g.FillRectangle(brush2, rectangle);
            }
        }

        public static void DrawStatusBlend(Graphics g, Rectangle rect, Color LightColor, Color DarkColor, float Angle)
        {
            Blend blend = new Blend();
            blend.Positions = new float[] { 0f, 0.25f, 0.25f, 0.57f, 0.86f, 1f };
            blend.Factors = new float[] { 0.1f, 0.6f, 1f, 0.4f, 0f, 0.95f };
            RectangleF ef = new RectangleF(0f, 1.5f, (float) rect.Width, (float) (rect.Height - 2));
            if ((ef.Width > 0f) && (ef.Height > 0f))
            {
                using (LinearGradientBrush brush = new LinearGradientBrush(ef, LightColor, DarkColor, 90f))
                {
                    brush.Blend = blend;
                    g.FillRectangle(brush, ef);
                }
            }
        }

        public static void DrawTabHeader(Graphics g, Point[] pt, Rectangle rect, Color LightColor, Color MiddleColor, Color ExtraColor, float Angle, TabAlignment Ta, bool Extended, TabHeaderStatus Status, bool PreserveColor)
        {
            switch (Ta)
            {
                case TabAlignment.Top:
                    Angle = 90f;
                    break;

                case TabAlignment.Left:
                    Angle = 0f;
                    break;

                case TabAlignment.Right:
                    Angle = 180f;
                    if (Extended)
                    {
                        switch (Status)
                        {
                            case TabHeaderStatus.Selected:
                                LightColor = ExtraColor;
                                break;

                            case TabHeaderStatus.HotSelected:
                                LightColor = ExtraColor;
                                break;
                        }
                    }
                    break;
            }
            bool flag1 = MiddleColor == Color.White;
            if (Extended)
            {
                g.FillPolygon(new LinearGradientBrush(rect, MiddleColor, LightColor, Angle), pt);
            }
            else
            {
                g.FillPolygon(GetBrush(rect, LightColor, MiddleColor, PaletteColorStyle.Default, Angle, (VisualOrientation) Ta, PreserveColor), pt);
            }
        }

        public static void DrawTabHeader(Graphics g, GraphicsPath path, Rectangle rect, Color LightColor, Color MiddleColor, Color ExtraColor, float Angle, TabAlignment Ta, bool Extended, TabHeaderStatus Status, bool PreserveColor)
        {
            switch (Ta)
            {
                case TabAlignment.Top:
                    Angle = 90f;
                    break;

                case TabAlignment.Left:
                    Angle = 0f;
                    break;

                case TabAlignment.Right:
                    Angle = 180f;
                    if (Extended)
                    {
                        switch (Status)
                        {
                            case TabHeaderStatus.Selected:
                                LightColor = ExtraColor;
                                break;

                            case TabHeaderStatus.HotSelected:
                                LightColor = ExtraColor;
                                break;
                        }
                    }
                    break;
            }
            if (MiddleColor == Color.White)
            {
                MiddleColor = GetDarkerColor(Color.White);
            }
            if (Extended)
            {
                g.FillPath(new LinearGradientBrush(rect, MiddleColor, LightColor, Angle), path);
            }
            else
            {
                g.FillPath(GetBrush(rect, LightColor, MiddleColor, PaletteColorStyle.Default, Angle, (VisualOrientation) Ta, PreserveColor), path);
            }
        }

        public static void DrawTabHeader(Graphics g, PointF[] pt, Rectangle rect, Color LightColor, Color MiddleColor, Color DarkColor, Color ExtraColor, float Angle, TabAlignment Ta, bool Extended, TabHeaderStatus Status)
        {
            float num = (rect.Height / 2) - 2;
            PointF[] points = new PointF[5];
            switch (Ta)
            {
                case TabAlignment.Top:
                    points[0] = pt[0];
                    points[1] = new PointF(pt[0].X, pt[2].Y + num);
                    points[2] = new PointF(pt[5].X, pt[3].Y + num);
                    points[3] = pt[5];
                    points[4] = pt[6];
                    Angle = 90f;
                    DarkColor = GetModifiedColor(DarkColor, 5, 0, 0);
                    MiddleColor = GetModifiedColor(MiddleColor, -10, 0, 0);
                    goto Label_04A2;

                case TabAlignment.Bottom:
                    points[0] = new PointF(pt[5].X, pt[4].Y - num);
                    points[1] = pt[0];
                    points[2] = pt[1];
                    points[3] = new PointF(pt[1].X, pt[3].Y - num);
                    points[4] = new PointF(pt[5].X, pt[4].Y - num);
                    Angle = 270f;
                    DarkColor = GetModifiedColor(DarkColor, 10, 0, 0);
                    MiddleColor = GetModifiedColor(MiddleColor, -10, 0, 0);
                    goto Label_04A2;

                case TabAlignment.Left:
                    num = (rect.Width / 2) - 2;
                    points[0] = new PointF(pt[3].X + num, pt[2].Y);
                    points[1] = new PointF(pt[4].X + num, pt[5].Y);
                    points[2] = pt[0];
                    points[3] = pt[1];
                    points[4] = new PointF(pt[3].X + num, pt[2].Y);
                    Angle = 0f;
                    DarkColor = GetModifiedColor(DarkColor, 10, 0, 0);
                    MiddleColor = GetModifiedColor(MiddleColor, -10, 0, 0);
                    goto Label_04A2;

                case TabAlignment.Right:
                    if (Extended)
                    {
                        points = new PointF[] { pt[0], pt[1], pt[2], pt[3], pt[4], pt[5], pt[6] };
                        Angle = 180f;
                        switch (Status)
                        {
                            case TabHeaderStatus.Normal:
                                LightColor = DarkColor;
                                DarkColor = GetModifiedColor(MiddleColor, 5, 0, 0);
                                MiddleColor = LightColor;
                                goto Label_04A2;

                            case TabHeaderStatus.NormalPreserve:
                                if (!(DarkColor == Color.White))
                                {
                                    DarkColor = GetModifiedColor(DarkColor, 5, 0, 0);
                                    break;
                                }
                                DarkColor = Color.WhiteSmoke;
                                break;

                            case TabHeaderStatus.Hot:
                            case TabHeaderStatus.HotSelected:
                                goto Label_04A2;

                            case TabHeaderStatus.Selected:
                                MiddleColor = ExtraColor;
                                goto Label_04A2;
                        }
                    }
                    else
                    {
                        num = (rect.Width / 2) - 2;
                        points[0] = pt[1];
                        points[1] = pt[0];
                        points[2] = new PointF(pt[4].X - num, pt[5].Y);
                        points[3] = new PointF(pt[3].X - num, pt[2].Y);
                        points[4] = pt[1];
                        Angle = 180f;
                        DarkColor = GetModifiedColor(DarkColor, 10, 0, 0);
                        MiddleColor = GetModifiedColor(MiddleColor, -10, 0, 0);
                    }
                    goto Label_04A2;

                default:
                    goto Label_04A2;
            }
            MiddleColor = LightColor;
        Label_04A2:
            if ((MiddleColor == Color.White) && (DarkColor == Color.White))
            {
                MiddleColor = Color.WhiteSmoke;
                DarkColor = Color.Snow;
            }
            using (LinearGradientBrush brush = new LinearGradientBrush(rect, LightColor, MiddleColor, Angle))
            {
                g.FillPolygon(brush, pt, FillMode.Winding);
            }
            using (LinearGradientBrush brush2 = new LinearGradientBrush(rect, Color.FromArgb(180, Color.White), Color.FromArgb(20, Color.White), Angle))
            {
                g.FillPolygon(brush2, pt, FillMode.Winding);
            }
            using (LinearGradientBrush brush3 = new LinearGradientBrush(rect, MiddleColor, DarkColor, Angle))
            {
                g.FillPolygon(brush3, points);
            }
        }

        public static Brush GetBrush(Rectangle rect, Color ColorBegin, Color ColorEnd, PaletteColorStyle ColorStyle, float Angle, VisualOrientation orientation, bool PreserveColors)
        {
            Blend blend = new Blend(4);
            Blend blend12 = new Blend();
            blend12.Positions = new float[] { 0f, 0.25f, 0.25f, 0.57f, 0.86f, 1f };
            blend12.Factors = new float[] { 0.1f, 0.6f, 1f, 0.4f, 0f, 0.95f };
            blend.Positions[0] = 0f;
            blend.Factors[0] = 1f;
            blend.Positions[1] = 0.4f;
            blend.Factors[1] = 0.5f;
            blend.Positions[2] = 0.4f;
            blend.Factors[2] = 0.1f;
            blend.Positions[3] = 1f;
            blend.Factors[3] = 0.9f;
            float[] numArray = new float[4];
            numArray[2] = 1f;
            numArray[3] = 1f;
            Blend blend2 = new Blend();
            float[] numArray2 = new float[4];
            numArray2[2] = 1f;
            numArray2[3] = 1f;
            blend2.Factors = numArray2;
            blend2.Positions = new float[] { 0f, 0.33f, 0.33f, 1f };
            Blend blend3 = new Blend();
            float[] numArray3 = new float[4];
            numArray3[2] = 1f;
            numArray3[3] = 1f;
            blend3.Factors = numArray3;
            blend3.Positions = new float[] { 0f, 0.5f, 0.5f, 1f };
            Blend blend4 = new Blend();
            float[] numArray4 = new float[4];
            numArray4[3] = 1f;
            blend4.Factors = numArray4;
            blend4.Positions = new float[] { 0f, 0.9f, 0.9f, 1f };
            Blend blend5 = new Blend();
            blend5.Factors = new float[] { 0f, 0.5f, 1f, 0.05f };
            blend5.Positions = new float[] { 0f, 0.45f, 0.45f, 1f };
            Blend blend6 = new Blend();
            blend6.Factors = new float[] { 0f, 0f, 0.25f, 0.7f, 1f, 1f };
            blend6.Positions = new float[] { 0f, 0.1f, 0.2f, 0.3f, 0.5f, 1f };
            Blend blend7 = new Blend();
            blend7.Factors = new float[] { 0.15f, 0.75f, 1f, 1f };
            blend7.Positions = new float[] { 0f, 0.45f, 0.45f, 1f };
            Blend blend8 = new Blend();
            blend8.Factors = new float[] { 0.8f, 0.2f, 0f, 0.07f, 1f };
            blend8.Positions = new float[] { 0f, 0.33f, 0.33f, 0.43f, 1f };
            Blend blend9 = new Blend();
            blend9.Factors = new float[] { 1f, 0.7f, 0.7f, 0f, 0.1f, 0.55f, 1f, 1f };
            blend9.Positions = new float[] { 0f, 0.16f, 0.33f, 0.35f, 0.51f, 0.85f, 0.85f, 1f };
            Blend blend10 = new Blend();
            blend10.Factors = new float[] { 1f, 0.78f, 0.48f, 1f, 1f };
            blend10.Positions = new float[] { 0f, 0.33f, 0.33f, 0.9f, 1f };
            new Blend();
            Blend blend11 = new Blend();
            blend11.Factors = numArray;
            blend11.Positions = new float[] { 0f, 0.25f, 0.25f, 1f };
            if (ColorStyle == PaletteColorStyle.Default)
            {
                LinearGradientBrush brush;
                if (PreserveColors)
                {
                    brush = new LinearGradientBrush(rect, ColorEnd, ColorBegin, Angle);
                }
                else
                {
                    brush = new LinearGradientBrush(rect, GetDarkerColor(ColorEnd), GetLighterColor(ColorBegin), Angle);
                }
                brush.Blend = blend;
                return brush;
            }
            if (ColorStyle == PaletteColorStyle.Solid)
            {
                return new SolidBrush(ColorBegin);
            }
            switch (orientation)
            {
                case VisualOrientation.Bottom:
                    Angle += 180f;
                    break;

                case VisualOrientation.Left:
                    Angle -= 90f;
                    break;

                case VisualOrientation.Right:
                    Angle += 90f;
                    break;
            }
            if (ColorStyle == PaletteColorStyle.OneNote)
            {
                ColorBegin = Color.White;
            }
            LinearGradientBrush brush2 = new LinearGradientBrush(rect, ColorBegin, ColorEnd, Angle);
            switch (ColorStyle)
            {
                case PaletteColorStyle.Switch25:
                    brush2.Blend = blend11;
                    return brush2;

                case PaletteColorStyle.Switch33:
                    brush2.Blend = blend2;
                    return brush2;

                case PaletteColorStyle.Switch50:
                    brush2.Blend = blend3;
                    return brush2;

                case PaletteColorStyle.Switch90:
                    brush2.Blend = blend4;
                    return brush2;

                case PaletteColorStyle.Linear:
                    return brush2;

                case PaletteColorStyle.Rounded:
                    brush2.SetSigmaBellShape(1f, 1f);
                    return brush2;

                case PaletteColorStyle.Rounding2:
                    brush2.Blend = blend8;
                    return brush2;

                case PaletteColorStyle.Rounding3:
                    brush2.Blend = blend9;
                    return brush2;

                case PaletteColorStyle.Rounding4:
                    brush2.Blend = blend10;
                    return brush2;

                case PaletteColorStyle.Sigma:
                    brush2.SetSigmaBellShape(0.5f);
                    return brush2;

                case PaletteColorStyle.HalfCut:
                    brush2.Blend = blend5;
                    return brush2;

                case PaletteColorStyle.QuarterPhase:
                    brush2.Blend = blend6;
                    return brush2;

                case PaletteColorStyle.OneNote:
                    brush2.Blend = blend7;
                    return brush2;

                case PaletteColorStyle.Status:
                    brush2.Blend = blend12;
                    return brush2;
            }
            return brush2;
        }

        public static Color GetDarkerColor(Color clr)
        {
            Color color = new Color();
            int red = clr.R - 0x12;
            int green = clr.G - 0x12;
            int blue = clr.B - 0x12;
            if (red < 0)
            {
                red = 0;
            }
            if (green < 0)
            {
                green = 0;
            }
            if (blue < 0)
            {
                blue = 0;
            }
            return Color.FromArgb(red, green, blue);
        }

        public static Color GetDarkerColor(Color clr, int amount)
        {
            Color color = new Color();
            int red = clr.R - amount;
            int green = clr.G - amount;
            int blue = clr.B - amount;
            if (red < 0)
            {
                red = 0;
            }
            if (green < 0)
            {
                green = 0;
            }
            if (blue < 0)
            {
                blue = 0;
            }
            return Color.FromArgb(red, green, blue);
        }

        public static Color GetLighterColor(Color clr)
        {
            Color color = new Color();
            int red = clr.R + 0x12;
            int green = clr.G + 0x12;
            int blue = clr.B + 0x12;
            if (red > 0xff)
            {
                red = 0xff;
            }
            if (green > 0xff)
            {
                green = 0xff;
            }
            if (blue > 0xff)
            {
                blue = 0xff;
            }
            return Color.FromArgb(red, green, blue);
        }

        public static Color GetLighterColor(Color clr, int amount)
        {
            Color color = new Color();
            int red = clr.R + amount;
            int green = clr.G + amount;
            int blue = clr.B + amount;
            if (red > 0xff)
            {
                red = 0xff;
            }
            if (green > 0xff)
            {
                green = 0xff;
            }
            if (blue > 0xff)
            {
                blue = 0xff;
            }
            return Color.FromArgb(red, green, blue);
        }

        public static Color GetModifiedColor(Color clr, int britness, int saturation, int hue)
        {
            Color color = new Color();
            ColorHandler.RGB rGB = new ColorHandler.RGB(clr.R, clr.G, clr.B);
            ColorHandler.HSV hSV = ColorHandler.RGBtoHSV(rGB);
            hSV.value += britness;
            hSV.Saturation += saturation;
            hSV.Hue += hue;
            rGB = ColorHandler.HSVtoRGB(hSV);
            int red = rGB.Red;
            int green = rGB.Green;
            int blue = rGB.Blue;
            if (red > 0xff)
            {
                red = 0xff;
            }
            if (green > 0xff)
            {
                green = 0xff;
            }
            if (blue > 0xff)
            {
                blue = 0xff;
            }
            if (red < 0)
            {
                red = 0;
            }
            if (green < 0)
            {
                green = 0;
            }
            if (blue < 0)
            {
                blue = 0;
            }
            return Color.FromArgb(red, green, blue);
        }

        public static PointF[] GetPoligonPointsFromPath(GraphicsPath path)
        {
            return path.PathPoints;
        }

        public static GraphicsPath GetRoundedBottomPath(Rectangle bounds, int radius, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize)
        {
            int x = bounds.X;
            int y = bounds.Y;
            int width = bounds.Width;
            int height = bounds.Height;
            GraphicsPath path = new GraphicsPath();
            if ((Appearance == TabAppearance.Normal) && ((Status == TabHeaderStatus.Selected) || (Status == TabHeaderStatus.HotSelected)))
            {
                path.AddLine(x, y, x + width, y);
                path.AddArc((x + width) - radius, (y + height) - radius, radius, radius, 0f, 90f);
                path.AddLine((int) ((x + width) - radius), (int) (y + height), (int) (x + radius), (int) (y + height));
                path.AddArc(x, (y + height) - radius, radius, radius, 90f, 90f);
            }
            else
            {
                path.AddLine(x, y, x + width, y);
                path.AddArc((x + width) - radius, ((y + height) - radius) - allowSelectedTabHighSize, radius, radius, 0f, 90f);
                path.AddLine((int) ((x + width) - radius), (int) ((y + height) - allowSelectedTabHighSize), (int) (x + radius), (int) ((y + height) - allowSelectedTabHighSize));
                path.AddArc(x, ((y + height) - radius) - allowSelectedTabHighSize, radius, radius, 90f, 90f);
            }
            path.CloseFigure();
            return path;
        }

        public static GraphicsPath GetRoundedLeftPath(Rectangle bounds, int radius)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(bounds);
            return path;
        }

        public static GraphicsPath GetRoundedRightPath(Rectangle bounds, int radius)
        {
            GraphicsPath path = new GraphicsPath();
            path.AddRectangle(bounds);
            return path;
        }

        public static GraphicsPath GetRoundedSquarePath(Rectangle bounds, int radius)
        {
            int x = bounds.X;
            int y = bounds.Y;
            int width = bounds.Width;
            int height = bounds.Height;
            GraphicsPath path = new GraphicsPath();
            path.AddArc(x, y, radius, radius, 180f, 90f);
            path.AddArc((x + width) - radius, y, radius, radius, 270f, 90f);
            path.AddArc((x + width) - radius, (y + height) - radius, radius, radius, 0f, 90f);
            path.AddArc(x, (y + height) - radius, radius, radius, 90f, 90f);
            path.CloseFigure();
            return path;
        }

        public static GraphicsPath GetRoundedTopPath(Rectangle bounds, int radius, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize)
        {
            int x = bounds.X;
            int y = bounds.Y;
            int width = bounds.Width;
            int height = bounds.Height;
            GraphicsPath path = new GraphicsPath();
            if ((Appearance == TabAppearance.Normal) && ((Status == TabHeaderStatus.Selected) || (Status == TabHeaderStatus.HotSelected)))
            {
                path.AddArc(x, y, radius, radius, 180f, 90f);
                path.AddLine(x + radius, y, ((x + width) - radius) - radius, y);
                path.AddArc((x + width) - radius, y, radius, radius, 270f, 90f);
                path.AddLine(x + width, y + height, x, y + height);
            }
            else
            {
                path.AddArc(x, y + allowSelectedTabHighSize, radius, radius, 180f, 90f);
                path.AddLine((int) (x + radius), (int) (y + allowSelectedTabHighSize), (int) (((x + width) - radius) - radius), (int) (y + allowSelectedTabHighSize));
                path.AddArc((x + width) - radius, y + allowSelectedTabHighSize, radius, radius, 270f, 90f);
                path.AddLine(x + width, y + height, x, y + height);
            }
            path.CloseFigure();
            return path;
        }

        public static Point[] GetSquaredBottomPoints(Rectangle recBounds, int cornerWidth, int cornerLeftWidth, int cornerRightWidth, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize)
        {
            Point[] pointArray = new Point[7];
            pointArray[0] = new Point(recBounds.Left, recBounds.Top);
            pointArray[1] = new Point(recBounds.Right, recBounds.Top);
            pointArray[2] = new Point(recBounds.Right, (recBounds.Bottom - cornerRightWidth) - allowSelectedTabHighSize);
            pointArray[3] = new Point(recBounds.Right - cornerRightWidth, recBounds.Bottom - allowSelectedTabHighSize);
            pointArray[4] = new Point(recBounds.Left + cornerLeftWidth, recBounds.Bottom - allowSelectedTabHighSize);
            pointArray[5] = new Point(recBounds.Left, (recBounds.Bottom - cornerLeftWidth) - allowSelectedTabHighSize);
            if ((Appearance == TabAppearance.Normal) && ((Status == TabHeaderStatus.Selected) || (Status == TabHeaderStatus.HotSelected)))
            {
                pointArray[2] = new Point(pointArray[2].X, pointArray[2].Y + allowSelectedTabHighSize);
                pointArray[3] = new Point(pointArray[3].X, pointArray[3].Y + allowSelectedTabHighSize);
                pointArray[4] = new Point(pointArray[4].X, pointArray[4].Y + allowSelectedTabHighSize);
                pointArray[5] = new Point(pointArray[5].X, pointArray[5].Y + allowSelectedTabHighSize);
            }
            pointArray[6] = new Point(recBounds.Left, recBounds.Top);
            return pointArray;
        }

        public static Point[] GetSquaredLeftPoints(Rectangle recBounds, int cornerWidth, int cornerLeftWidth, int cornerRightWidth, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize)
        {
            return new Point[] { new Point(recBounds.Right, recBounds.Top), new Point(recBounds.Right, recBounds.Bottom), new Point(recBounds.Left + cornerWidth, recBounds.Bottom), new Point(recBounds.Left, recBounds.Bottom - cornerWidth), new Point(recBounds.Left, recBounds.Top + cornerWidth), new Point(recBounds.Left + cornerWidth, recBounds.Top), new Point(recBounds.Right, recBounds.Top) };
        }

        public static Point[] GetSquaredRightPoints(Rectangle recBounds, int cornerWidth, int cornerLeftWidth, int cornerRightWidth, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize)
        {
            return new Point[] { new Point(recBounds.Left, recBounds.Top), new Point(recBounds.Left, recBounds.Bottom), new Point(recBounds.Right - cornerWidth, recBounds.Bottom), new Point(recBounds.Right, recBounds.Bottom - cornerWidth), new Point(recBounds.Right, recBounds.Top + cornerWidth), new Point(recBounds.Right - cornerWidth, recBounds.Top), new Point(recBounds.Left, recBounds.Top) };
        }

        public static Point[] GetSquaredTopPoints(Rectangle recBounds, int cornerWidth, int cornerLeftWidth, int cornerRightWidth, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize)
        {
            Point[] pointArray = new Point[7];
            pointArray[0] = new Point(recBounds.Left, recBounds.Bottom);
            pointArray[1] = new Point(recBounds.Left, (recBounds.Top + cornerLeftWidth) + allowSelectedTabHighSize);
            pointArray[2] = new Point(recBounds.Left + cornerLeftWidth, recBounds.Top + allowSelectedTabHighSize);
            pointArray[3] = new Point(recBounds.Right - cornerRightWidth, recBounds.Top + allowSelectedTabHighSize);
            pointArray[4] = new Point(recBounds.Right, (recBounds.Top + cornerRightWidth) + allowSelectedTabHighSize);
            if ((Appearance == TabAppearance.Normal) && ((Status == TabHeaderStatus.Selected) || (Status == TabHeaderStatus.HotSelected)))
            {
                pointArray[1] = new Point(pointArray[1].X, pointArray[1].Y - allowSelectedTabHighSize);
                pointArray[2] = new Point(pointArray[2].X, pointArray[2].Y - allowSelectedTabHighSize);
                pointArray[3] = new Point(pointArray[3].X, pointArray[3].Y - allowSelectedTabHighSize);
                pointArray[4] = new Point(pointArray[4].X, pointArray[4].Y - allowSelectedTabHighSize);
            }
            pointArray[5] = new Point(recBounds.Right, recBounds.Bottom);
            pointArray[6] = new Point(recBounds.Left, recBounds.Bottom);
            return pointArray;
        }

        public static Color GetSystemDarkerColor(Color clr)
        {
            return ControlPaint.Dark(clr);
        }

        public static Color GetSystemDarkerDarkColor(Color clr)
        {
            return ControlPaint.DarkDark(clr);
        }

        public static Color GetSystemLighterColor(Color clr)
        {
            return ControlPaint.Light(clr);
        }

        public static Color GetSystemLighterLightColor(Color clr)
        {
            return ControlPaint.LightLight(clr);
        }

        public static GraphicsPath GetTabRoundedPath(Rectangle bounds, int radius, TabAlignment orientation, bool IsForBorder, TabHeaderStatus Status, TabAppearance Appearance, int allowSelectedTabHighSize)
        {
            GraphicsPath path = new GraphicsPath();
            switch (orientation)
            {
                case TabAlignment.Top:
                    if (IsForBorder)
                    {
                        bounds.Offset(1, 1);
                        bounds.Width -= 2;
                        if ((Status != TabHeaderStatus.HotSelected) && (Status != TabHeaderStatus.Selected))
                        {
                            bounds.Height -= 2;
                        }
                    }
                    return GetRoundedTopPath(bounds, radius, Appearance, Status, allowSelectedTabHighSize);

                case TabAlignment.Bottom:
                    if (!IsForBorder)
                    {
                        goto Label_00A4;
                    }
                    if ((Status == TabHeaderStatus.HotSelected) || (Status == TabHeaderStatus.Selected))
                    {
                        bounds.Offset(1, -1);
                        break;
                    }
                    bounds.Offset(1, 1);
                    bounds.Height -= 2;
                    break;

                case TabAlignment.Left:
                    if (IsForBorder)
                    {
                        bounds.Offset(1, 1);
                        bounds.Height -= 2;
                        if ((Status != TabHeaderStatus.HotSelected) && (Status != TabHeaderStatus.Selected))
                        {
                            bounds.Width -= 2;
                        }
                    }
                    return GetRoundedLeftPath(bounds, radius);

                case TabAlignment.Right:
                    if (IsForBorder)
                    {
                        if ((Status == TabHeaderStatus.HotSelected) || (Status == TabHeaderStatus.Selected))
                        {
                            bounds.Offset(-1, 1);
                        }
                        else
                        {
                            bounds.Offset(1, 1);
                            bounds.Width -= 2;
                        }
                        bounds.Height -= 2;
                    }
                    return GetRoundedRightPath(bounds, radius);

                default:
                    return path;
            }
            bounds.Width -= 2;
        Label_00A4:
            return GetRoundedBottomPath(bounds, radius, Appearance, Status, allowSelectedTabHighSize);
        }

        public static Point[] GetTabSquaredPoints(Rectangle bounds, int cornerWidth, TabAlignment orientation, int cornerLeftWidth, int cornerRightWidth, TabAppearance Appearance, TabHeaderStatus Status, int allowSelectedTabHighSize, bool IsForBorder)
        {
            Point[] pointArray = new Point[7];
            switch (orientation)
            {
                case TabAlignment.Top:
                    if (IsForBorder)
                    {
                        bounds.Offset(1, 1);
                        bounds.Width -= 2;
                        if ((Status != TabHeaderStatus.HotSelected) && (Status != TabHeaderStatus.Selected))
                        {
                            bounds.Height -= 2;
                        }
                    }
                    return GetSquaredTopPoints(bounds, cornerWidth, cornerLeftWidth, cornerRightWidth, Appearance, Status, allowSelectedTabHighSize);

                case TabAlignment.Bottom:
                    if (!IsForBorder)
                    {
                        goto Label_00AA;
                    }
                    if ((Status == TabHeaderStatus.HotSelected) || (Status == TabHeaderStatus.Selected))
                    {
                        bounds.Offset(1, -1);
                        break;
                    }
                    bounds.Offset(1, 1);
                    bounds.Height -= 2;
                    break;

                case TabAlignment.Left:
                    if (IsForBorder)
                    {
                        bounds.Offset(1, 1);
                        bounds.Height -= 2;
                        if ((Status != TabHeaderStatus.HotSelected) && (Status != TabHeaderStatus.Selected))
                        {
                            bounds.Width -= 2;
                        }
                    }
                    return GetSquaredLeftPoints(bounds, cornerWidth, cornerLeftWidth, cornerRightWidth, Appearance, Status, allowSelectedTabHighSize);

                case TabAlignment.Right:
                    if (IsForBorder)
                    {
                        if ((Status == TabHeaderStatus.HotSelected) || (Status == TabHeaderStatus.Selected))
                        {
                            bounds.Offset(-1, 1);
                        }
                        else
                        {
                            bounds.Offset(1, 1);
                            bounds.Width -= 2;
                        }
                        bounds.Height -= 2;
                    }
                    return GetSquaredRightPoints(bounds, cornerWidth, cornerLeftWidth, cornerRightWidth, Appearance, Status, allowSelectedTabHighSize);

                default:
                    return pointArray;
            }
            bounds.Width -= 2;
        Label_00AA:
            return GetSquaredBottomPoints(bounds, cornerWidth, cornerLeftWidth, cornerRightWidth, Appearance, Status, allowSelectedTabHighSize);
        }

        public enum CornerType
        {
            Rounded,
            Squared
        }

        public enum PaletteColorStyle
        {
            Default,
            Solid,
            Switch25,
            Switch33,
            Switch50,
            Switch90,
            Linear,
            Rounded,
            Rounding2,
            Rounding3,
            Rounding4,
            Sigma,
            HalfCut,
            QuarterPhase,
            OneNote,
            Status
        }

        public enum TabHeaderStatus
        {
            Normal,
            NormalPreserve,
            Hot,
            Selected,
            HotSelected
        }

        public enum VisualOrientation
        {
            Top,
            Bottom,
            Left,
            Right
        }
    }
}

